/*
 * adc_interface.cpp
 *
 *  Created on: 2013-8-16
 *      Author: test
 */

#include "dev_adc.h"
#include "dev_common.h"
#include "DSP2833x_Device.h"

volatile unsigned short* adc_reg_ctrl1 = (volatile unsigned short*)&AdcRegs.ADCTRL1.all;
volatile unsigned short* adc_reg_ctrl2 = (volatile unsigned short*)&AdcRegs.ADCTRL2.all;
volatile unsigned short* adc_reg_ctrl3 = (volatile unsigned short*)&AdcRegs.ADCTRL3.all;
volatile unsigned short* adc_reg_maxConv = (volatile unsigned short*)&AdcRegs.ADCMAXCONV.all;
volatile unsigned short* adc_reg_sta	= (volatile unsigned short*)&AdcRegs.ADCST.all;
volatile unsigned short* adc_reg_ref	= (volatile unsigned short*)&AdcRegs.ADCREFSEL.all;
volatile unsigned short* adc_reg_seqChan1 = (volatile unsigned short*)&AdcRegs.ADCCHSELSEQ1.all;
volatile unsigned short* adc_reg_seqChan2 = (volatile unsigned short*)&AdcRegs.ADCCHSELSEQ2.all;
volatile unsigned short* adc_reg_seqChan3 = (volatile unsigned short*)&AdcRegs.ADCCHSELSEQ3.all;
volatile unsigned short* adc_reg_seqChan4 = (volatile unsigned short*)&AdcRegs.ADCCHSELSEQ4.all;

volatile unsigned short* adc_reg_result = (volatile unsigned short*)&AdcRegs.ADCRESULT0;
volatile unsigned short* adc_mir_result = (volatile unsigned short*)&AdcMirror.ADCRESULT0;

void adc_init(){
    EALLOW;
	SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
	EDIS;

	AdcRegs.ADCTRL1.bit.RESET = 1;

    AdcRegs.ADCTRL3.all = 0x00E0;  // Power up bandgap/reference/ADC circuits
    deviceDelay(500);
}


